// 待审核 table-head
function ListColumns(_this) {
  let vm = _this
  let head = [{
      type: 'selection',
      width: 35,
      align: 'center',
      render(h, params) {
        return h('span', 'test')
      },
    },
    {
      title: '序号',
      key: 'name',
      minWidth: 40,
      align: 'center',
      render(h, params) {
        return h('div', params.row._index - 0 + 1)
      },
    },
    {
      title: '批次名称',
      key: 'batchName',
      minWidth: 180,
      align: 'center',
      render: (h, params) => {
        return h('div', params.row.batchName ? params.row.batchName : '-')
      },
    },
    {
      title: '证件类型',
      key: 'certType',
      minWidth: 120,
      align: 'center',
      render: (h, params) => {
        return h(
          'div',
          params.row.certType == '1' ? '预售许可证' : '出售许可证'
        )
      },
    },
    {
      title: '证件编号',
      key: 'certCode',
      minWidth: 180,
      align: 'center',
      render: (h, params) => {
        return h('div', params.row.certCode ? params.row.certCode : '-')
      },
    },
    {
      title: '开盘时间',
      key: 'firstOpenTime',
      minWidth: 120,
      align: 'center',
      render: (h, params) => {
        return h(
          'div',
          params.row.firstOpenTime ? params.row.firstOpenTime : '-'
        )
      },
    },
    {
      title: '是否关联产品',
      key: 'isRelation',
      minWidth: 120,
      align: 'center',
      render: (h, params) => {
        return h('div', params.row.isRelation ? '已关联' : '未关联')
      },
    },
    {
      title: '操作',
      key: 'operation',
      width: 180,
      align: 'center',
      render: (h, params) => {
        return h('div', [
          h(
            'a', {
              style: {
                marginRight: '10px',
              },
              on: {
                click: (e) => {
                  e.stopPropagation()
                  vm.editChannel(params.row, 'check')
                },
              },
            },
            '查看'
          ),
          h(
            'a', {
              style: {
                marginRight: '10px',
                display: params.row.certType == 1 ?
                  vm.compare(params.row.firstOpenTime) ?
                  'none' :
                  'inline-block' : params.row.isRelation ?
                  'none' : 'inline-block',
                cursor: vm.unlocking('0102010203') ?
                  'pointer' : 'not-allowed',
                color: vm.unlocking('0102010203') ? '#2d8cf0' : '#c5c8ce',
              },
              on: {
                click: (e) => {
                  e.stopPropagation()
                  vm.unlocking('0102010203') &&
                    vm.editChannel(params.row, 'edit')
                },
              },
            },
            '编辑'
          ),
          h(
            'a', {
              style: {
                display: params.row.isRelation ? 'none' : 'inline-block',
                cursor: vm.unlocking('0102010202') ?
                  'pointer' : 'not-allowed',
                color: vm.unlocking('0102010202') ? '#2d8cf0' : '#c5c8ce',
              },
              on: {
                click: (e) => {
                  e.stopPropagation()
                  vm.unlocking('0102010202') &&
                    vm.delChannel(params.row)
                },
              },
            },
            '删除'
          ),
        ])
      },
    },
  ]
  return head
}

function ModalColumns(_this) {
  let vm = _this
  let head = [{
      title: '序号',
      key: 'name',
      minWidth: 50,
      align: 'center',
      render(h, params) {
        return h('div', params.row._index - 0 + 1)
      },
    },
    {
      title: '产品',
      key: 'productName',
      minWidth: 180,
      align: 'center',
    },
    {
      title: '楼栋',
      key: 'buildingName',
      minWidth: 120,
      align: 'center',
    },
    {
      title: '操作',
      key: 'operation',
      width: 80,
      align: 'center',
      render: (h, params) => {
        return h('div', [
          h(
            'a', {
              style: {
                display: params.row.isCanDel && vm.unlocking('0102010204') ?
                  'inline-block' : 'none',
              },
              on: {
                click: (e) => {
                  e.stopPropagation()
                  vm.delProdectOrBuild(params.row, vm.isdisabled)
                },
              },
            },
            '删除'
          ),
        ])
      },
    },
  ]
  return head
}

function rule() {
  let ruleValidate = {
    batchName: [{
      required: true,
      message: '请输入批次名称',
      trigger: 'blur'
    }, ],
    certCode: [{
      required: true,
      message: '请输入许可证编号',
      trigger: 'blur'
    }, ],
    firstOpenTime: [{
      required: true,
      type: 'date',
      message: '请选择开盘时间',
      trigger: 'blur',
    }, ],
    imageVOS: [{
      required: true,
      type: 'array',
      message: '请上传许可证附件',
      trigger: 'change',
    }, ],
  }
  return ruleValidate
}
export default {
  ListColumns,
  ModalColumns,
  rule
}